package com.cskaoyan.javse.oop3._1interface._3exercise;

/**
 * @description: 链式调用
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

/**
 * 链式调用就是能够在前面的基础上,再次去调用一个方法,很多方法调用组合在一起就是一条链式调用
 *
 * 链式调用的前提是前面方法调用返回的是对象
 *
 * 链式调用的经典实用就是Stream API
 */
public class Demo2 {
    public static void main(String[] args) {
        Student s = new Student();
        Student s2 = s.getStudent();
        Teacher t = s2.getTeacher();
        t.show();

        //上述代码全部可以合成一条语句,称之为"链式调用"
        new Student().getStudent().getTeacher().show();
    }
}
class Student{

    public Student() {
    }

    public Student getStudent(){
        return new Student();
    }

    public Teacher getTeacher(){
        return new Teacher();
    }
}
class Teacher{
    public void show(){
        System.out.println("秀一波~~~");
    }
}